package com.jucai.pppeiyouclient.view.popup;

import android.app.Activity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.Window;

import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.adapter.ComplaintAdapter;
import com.jucai.pppeiyouclient.base.BasePopup;
import com.jucai.pppeiyouclient.base.CommonRecyclerViewAdapter;
import com.jucai.pppeiyouclient.comm.CommonMethod;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Kuky on 2017-05-02.
 */

public class ComplaintReasonPopup extends BasePopup {
    private View popupView;
    private RecyclerView reasonRv;
    private ComplaintAdapter complaintAdapter;
    private List<String> strings = new ArrayList<>();

    public void setPopupStrs(List<String> strings, CommonRecyclerViewAdapter.OnItemClickListener onItemClickListener) {
        this.strings = strings;
        complaintAdapter.setData(strings);
        complaintAdapter.setOnItemClickListener(onItemClickListener);
    }

    public ComplaintReasonPopup(Activity activity, Window window, int animationStyle, View.OnClickListener onClickListener) {
        super(activity, R.layout.popup_complaint_reason, window, animationStyle, onClickListener);
    }

    public ComplaintReasonPopup(Activity activity, int resourceId, Window window, int animationStyle, int width, View.OnClickListener onClickListener) {
        super(activity, resourceId, window, animationStyle, width, onClickListener);
    }

    public ComplaintReasonPopup(Activity activity, int resourceId, Window window, int animationStyle, int width, int height, View.OnClickListener onClickListener) {
        super(activity, resourceId, window, animationStyle, width, height, onClickListener);
    }

    @Override
    protected View getView(Activity activity, int resource, View.OnClickListener onClickListener) {
        popupView = CommonMethod.getView(activity, resource);

        complaintAdapter = new ComplaintAdapter(activity, strings);
        reasonRv = (RecyclerView) popupView.findViewById(R.id.popup_reason);
        reasonRv.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false));
        reasonRv.setItemAnimator(new DefaultItemAnimator());
        reasonRv.setAdapter(complaintAdapter);

        return popupView;
    }
}
